/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class EquipmentInfoMaintainDataAccess {
        public List<EquipmentInfoMaintain_Entity> EquipmentInfoMaintain_ListByPaging(int pageSize, int pageIndex, out int total) {
            total = 0;
            try {
                int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("EquipmentInfoMaintain_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
                cmd.SetParameterValue("@RecordCount", tempRecord);
                List<EquipmentInfoMaintain_Entity> pageList = cmd.ExecuteEntityList<EquipmentInfoMaintain_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<EquipmentInfoMaintain_Entity>(0);

        }

        public EquipmentInfoMaintain_Entity EquipmentInfoMaintain_View(System.Int32 EquipmentID) {
            EquipmentInfoMaintain_Entity c = default(EquipmentInfoMaintain_Entity);
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("EquipmentInfoMaintain_View");
                cmd.SetParameterValue("@EquipmentID", EquipmentID);
                c = cmd.ExecuteEntity<EquipmentInfoMaintain_Entity>();
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public EquipmentInfoMaintain_Entity EquipmentInfoMaintain_Add(EquipmentInfoMaintain_Entity entity) {
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("EquipmentInfoMaintain_Add");
                cmd.SetParameterValue("@EquipmentID", entity.EquipmentID);
                cmd.SetParameterValue("@EquipmentName", entity.EquipmentName);
                cmd.SetParameterValue("@EquipmentType", entity.EquipmentType);
                cmd.SetParameterValue("@Quantity", entity.Quantity);
                cmd.SetParameterValue("@Desciption", entity.Desciption);
                cmd.SetParameterValue("@BuyTime", entity.BuyTime);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.ExecuteNonQuery();
                entity.EquipmentID = (int)cmd.GetParameterValue("@EquipmentID");
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool EquipmentInfoMaintain_Update(EquipmentInfoMaintain_Entity entity) {
            bool succ = false;
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("EquipmentInfoMaintain_Update");
                cmd.SetParameterValue("@EquipmentID", entity.EquipmentID);
                cmd.SetParameterValue("@EquipmentName", entity.EquipmentName);
                cmd.SetParameterValue("@EquipmentType", entity.EquipmentType);
                cmd.SetParameterValue("@Quantity", entity.Quantity);
                cmd.SetParameterValue("@Desciption", entity.Desciption);
                cmd.SetParameterValue("@BuyTime", entity.BuyTime);
                cmd.SetParameterValue("@CompanyID", entity.CompanyID);
                cmd.SetParameterValue("@CreateDate", entity.CreateDate);
                cmd.SetParameterValue("@UpdateDate", entity.UpdateDate);
                cmd.SetParameterValue("@AuditStatus", entity.AuditStatus);
                cmd.SetParameterValue("@AuditDate", entity.AuditDate);
                cmd.SetParameterValue("@IsDeleted", entity.IsDeleted);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool EquipmentInfoMaintain_Delete(System.Int32 EquipmentID) {
            bool succ = false;
            try {
                DataCommand cmd = DataCommandManager.GetDataCommand("EquipmentInfoMaintain_Delete");
                cmd.SetParameterValue("@EquipmentID", EquipmentID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

    }
}
